<template>
    <div :class="isFirst ? 'titleComponent-wrap-first' : 'titleComponent-wrap'">
        <div class="line"></div>
        <div>{{ title }}</div>
        <i class="el-icon-d-arrow-right" v-if="path" @click="goLink"></i>
    </div>
</template>

<script>
import store from '@/store'
export default {
    name: "titleComponent",
    props: {
        title: {
            type: String,
            default: ''
        },
        isFirst: {
            type: Boolean,
            default: () => false
        },
        path: {
            type: String,
            default: ''
        },
        orgId: {
            type: String,
            default: ''
        },
        yearFilter: {
            type: String,
            default: ''
        }
    },
    mounted() {
    },
    data() {
        return {
        }
    },
    mounted() {
    },
    methods: {
        goLink() {
            if (this.title.indexOf('项目健康度') > -1) {
                window.top.postMessage(
                    JSON.stringify({
                        to: 'portal',
                        action: 'open',
                        pathname: '/iframe/TYMH_MENU_ProjectHealthEightData',
                    }),
                    '*'
                )
            } else if (this.title === 'OKR工作任务调度') {
                let loginCode = store.getters.loginCode
                window.open(`${this.path}?loginCode=${loginCode}`)
            } else {
                this.$router.push({ path: this.path, query: { cityCode: this.orgId == '10008' ? '' : this.orgId, type: 'totalIncome' } });
            }
        }
    }

}
</script>

<style scoped lang="scss">
.titleComponent-wrap-first {
    color: #333;
    font-size: 18px;
    font-weight: bold;
}

.titleComponent-wrap {
    overflow: hidden;
    box-sizing: border-box;
    height: 20px;
    line-height: 20px;
    font-size: 19px;
    font-weight: bolder;
    display: flex;

    .line {
        width: 4px;
        height: 20px;
        background: #0b82ff;
        border-radius: 8px;
        margin-right: 8px;
    }
}

.el-icon-d-arrow-right {
    margin-left: 5px;
    cursor: pointer;

    &:hover {
        color: #0b82ff;
    }
}
</style>
